// ==UserScript==
// @name         Paste And Search
// @include      main
// @author       Cye3s
// @version      1.0.20081010
// ==/UserScript==
document.getElementById("searchbar").addEventListener("popupshowing", function(event) {
	const eltID = "pasteandsearch-menuitem";
	var menupopup = event.originalTarget;
	var refChild = menupopup.getElementsByAttribute("cmd", "cmd_paste")[0];
	var canPaste = refChild.getAttribute("disabled") == "true";
	var menuitem = document.getElementById(eltID);
	if (!menuitem) {
		var pasteAndSearch = function(event) {
			goDoCommand("cmd_paste");
			document.getElementById("searchbar").handleSearchCommand(event);
			menupopup.hidePopup();
		};
		menuitem = document.createElement("menuitem");
		menuitem.id = eltID;
		menuitem.setAttribute("label", "\u7C98\u8D34\u5E76\u641C\u7D22");
        menuitem.setAttribute("accesskey", "G");
		menuitem.addEventListener("command", pasteAndSearch, false);
		menupopup.insertBefore(menuitem, refChild.nextSibling);
	}
	menuitem.setAttribute("disabled", canPaste.toString());
}, false);
            